<template>
  <TableList :data="tableData" @showAddDialog="showAddDialog" @refresh="loadData"></TableList>
  <AddForm :visiable="addVisiable" @closeAddDialog="closeAddDialog" @refresh="loadData"></AddForm>
</template>
<script setup lang="js">
import { ref, onMounted } from 'vue'
import TableList from './components/TableList.vue';
import AddForm from './components/AddForm.vue'
import { getList } from '@/api/dept_api';

const tableData = ref([])
const addVisiable = ref(false)

onMounted(() => {
  loadData()
})

const loadData = async () => {
  let resp = await getList()
  console.log("重新加载：", resp);
  tableData.value = []
  tableData.value.push(resp)
  console.log("aaaa", tableData.value);

}

const showAddDialog = () => {
  addVisiable.value = true
}
const closeAddDialog = () => {
  addVisiable.value = false
}
</script>